package com.cy.pj.sys.service.impl;

import com.cy.pj.common.annotation.RequiredLog;
import com.cy.pj.common.annotation.RequiredTime;
import com.cy.pj.sys.dao.SysLogDao;
import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService {

    @Autowired
    private SysLogDao sysLogDao;

//    @RequiredTime
    @RequiredLog(operation="公告查询")
    @Override
    public List<SysLog> findLogs(SysLog sysLog) {
        List<SysLog> list = sysLogDao.selectLogs(sysLog);
        return list;
    }

    @Override
    public SysLog findById(Long id) {
        SysLog log = sysLogDao.selectById(id);
        return log;
    }

    @Transactional(readOnly = true)
    @Async
    @Override
    public void insertLog(SysLog sysLog) {
        sysLogDao.insertLog(sysLog);
    }

    @Transactional
    @Override
    public int deleteById(Long... ids) {
        int rows = sysLogDao.deleteById(ids);
        return rows;
    }
}
